package ui.activity.mine.biz;

import java.util.List;

import Bean.GetBankcardBean;
import Bean.TiXianBean;
import base.BaseBiz;
import base.BaseResp;
import coom.BaseSubscribe;
import coom.RetrofitHelp;
import okhttp3.RequestBody;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import ui.activity.poscontrol.beanmodel.TiXianResultBean;
import ui.model.AccountMoneyInfo;
import ui.model.ItemsInfo;
import ui.model.WithDrawInfo;

/**
 * Created by chenjian on 19/2/26.
 * 1
 */

public class ReturnIncomeBiz extends BaseBiz {
    /**
     * 获取银行卡列表
     */
    public void getCardList(final Callback<GetBankcardBean.DataBean> callback) {
        com.add(RetrofitHelp.getSecretApi().cardList()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe<BaseResp<GetBankcardBean.DataBean>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((GetBankcardBean.DataBean) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((GetBankcardBean.DataBean) obj);
                    }
                })
        );
    }

    /**
     * 获取钱包信息
     */
    public void getUserIncome(final Callback<ItemsInfo<AccountMoneyInfo>> callback) {
        com.add(RetrofitHelp.getSecretApi().accountInfo()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe<BaseResp<ItemsInfo<AccountMoneyInfo>>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((ItemsInfo<AccountMoneyInfo>) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((ItemsInfo<AccountMoneyInfo>) obj);
                    }
                })
        );
    }

    /**
     * 申请提现
     */
    public void setIncome(RequestBody requestBody, final Callback<List<TiXianResultBean>> callback) {
        com.add(RetrofitHelp.getSecretApi().applyMoneyNew(requestBody)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe<BaseResp<List<TiXianResultBean>>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((List<TiXianResultBean>) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((List<TiXianResultBean>) obj);
                    }
                })
        );
    }

    /**
     * 余额获取验证码
     */
    public void yuPay(final Callback<Object> callback) {
        com.add(RetrofitHelp.getSecretApi().getCode()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe<BaseResp<Object>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((Object) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((Object) obj);
                    }
                })
        );
    }

    /**
     * 获取是否设置提现密码
     */
    public void getPwd(final Callback<Boolean> callback) {
        com.add(RetrofitHelp.getSecretApi().payPassWord()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe<BaseResp<Boolean>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((Boolean) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((Boolean) obj);
                    }
                })
        );
    }


    /**
     * 获取提现信息
     */
    public void getWithDrawInfo(final Callback<WithDrawInfo> callback) {
        com.add(RetrofitHelp.getSecretApi().withDrawInfo()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe<BaseResp<WithDrawInfo>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((WithDrawInfo) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((WithDrawInfo) obj);
                    }
                })
        );
    }

    /**
     * 获取提现信息
     */
    public void getWithTixianType(final Callback<TiXianBean> callback) {
        com.add(RetrofitHelp.getSecretApi().getuserTixiantype()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscribe<BaseResp<TiXianBean>>() {

                    @Override
                    public void onSuccess(Object obj) {
                        callback.onSuccess((TiXianBean) obj);
                    }

                    @Override
                    public void onFailure(Object obj) {
                        callback.onFailure((TiXianBean) obj);
                    }
                })
        );
    }
}
